<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<script type="text/javascript" src="../../../static/lib/jquery.min.js" ></script>
	<link rel="stylesheet" href="../../../static/plugg/layui/css/modules/layer/default/layer.css">
	<script type="text/javascript" src="../../../static/plugg/layui/lay/modules/layer.js" ></script>
	<link rel="stylesheet" href="../../../static/tdh/btn/css/btn.css" />
	<script type="text/javascript" src="../../../static/tdh/btn/js/tdh.btn.js" ></script>
</head>
<body>
	<a id="test" class="tdh_btn tdh_btn_blue">选择地区</a>
	<input id="input" type="text" />
	<script>
		$('#test').on('click', function(){
			layer.open({
				id: 'selarea',
				type: 2,
				title: '选择地区',
				shadeClose: true,
				shade: 0.8,
				area: ['860px', '450px'],
				content: '../../tdh/area/area.html',
				btn:['确定','清除'],
				success: function(index, layero){
					var frameId=document.getElementById('selarea').getElementsByTagName('iframe')[0].id;
					var val=$('#input').attr('data-value');
					if(val){
						$('#'+frameId).contents().find('#area_input').val(val);
					}
				},
				yes: function(index, layero){
					var frameId=document.getElementById('selarea').getElementsByTagName('iframe')[0].id;
    				var areadm=$('#'+frameId)[0].contentWindow.myArea.getArea(),
    					areastr=$('#'+frameId)[0].contentWindow.myArea.getAreaName(areadm);
                    $('#input').val(areastr).attr('data-value',areadm);//输出地区
                    layer.close(index);
				},btn2 :function(index, layero){
					var frameId=document.getElementById('selarea').getElementsByTagName('iframe')[0].id;
    				$('#'+frameId)[0].contentWindow.myArea.clear();
					return false;
				}
			}); 
		});
	</script>
</body>
</html>
